
// 解析路由参数
export const getUrlParams = url => {
	if (!url) return null;
	const allQuerys = decodeURIComponent(url).split("?")[1];
	if (!allQuerys) return null;
	let res = {};
	if (allQuerys.indexOf("&") === -1) {
		const temp = allQuerys.split("=");
		res[temp[0]] = temp[1];
	} else {
		const arr = allQuerys.split("&");
		for (let item of arr) {
			const temp = item.split("=");
			res[temp[0]] = temp[1];
		}
	}
	return res;
};

// h5环境区分安卓和ios
export const isAndroidOrIOS = () => {
	var u = navigator.userAgent;
	var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1;
	var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
	if (isAndroid) {
		return "android";
	}
	if (isiOS) {
		return "ios";
	}
	return false;
};